<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>切换图片</title>
		<style>
			div {
				border: 1px solid white;
				width: 500px;
				height: 350px;
				margin: auto;
				text-align: center;
			}
		</style>
		<script>
			var i = 1;

			function changeImg() {
				i++;
				document.getElementById("img").src = "../../img/" + i + ".jpg";
				if(i == 3) {
					i = 0;
				}
			}
		</script>
	</head>

	<body>
		<div>
			<input type="button" value="下一张" onclick="changeImg()" />
			<img src="../../img/1.jpg" width="100%" height="100%" id="img" />
		</div>
	</body>

</html>